﻿using System;
using System.Windows.Forms;

namespace Vendas.Dialogs
{
    public partial class FormNumeroMesa : DevExpress.XtraEditors.XtraForm
    {
        public FormNumeroMesa()
        {
            InitializeComponent();
        }
        public FormNumeroMesa(string texto)
        {
            InitializeComponent();
            lblTexto.Text = texto;
        }

        public int GetMesa(){
            numMesa.SelectAll();
            ShowDialog();
            if (this.DialogResult == DialogResult.Cancel)
            {
                return 0;
            }
            return  Convert.ToInt32(numMesa.Text);
        }

        public int GetMesa(String texto)
        {
            lblTexto.Text = texto;
            return GetMesa();
        }
        private void FormNumeroMesa_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
        {
            if (e.KeyData == Keys.Enter)
            {
                DialogResult = DialogResult.Yes;
                Close();
            }
            if (e.KeyData == Keys.Escape)
            {
                DialogResult = DialogResult.Cancel;
                Close();
            }
        }

        private void numMesa_KeyDown(object sender, KeyEventArgs e)
        {
            
        }
    }
}